//-
//- Copyright (c) Microsoft. All rights reserved.
//- Licensed under the MIT license. See LICENSE file in the project root for full license information.
//-

extends ../../layout

block content
  .container
    .row: .col-sm-12
      .nav
        ul.pager.zero-pad-bottom
          li.previous
            a(href='/' + organization.name + '/repos/' + repository.name)
              span(aria-hidden=true) &larr;
              = ' Back to the ' + repository.name + ' repository'

    if !npmUsername
      .row: .col-sm-12
        h2 Please create and/or register your NPM account
        p.
          To enable NPM publishing, you must register your NPM username. After the package has
          been published, your NPM account will be given collaborator/owner status so that you
          may publish the package with your own account in the future.

        ul.list-inline
          li: a.btn.btn-primary(href='/settings/npm') Register existing NPM username
          li: a.btn.btn-default(href='https://www.npmjs.com/signup', target='_new') Create an NPMJS account

        hr

        p: small.
          After registering your account, come back to this page to continue package publishing. If
          you created a new NPMJS account, you will also need to refresh this page first.

    else
      .row: .col-sm-12
        h1 NPM publishing
      .row
        .col-md-8

          p.lead A repository with a #[code package.json] file can be published to the NPM registry.

          form(method='post', action='/' + organization.name + '/repos/' + repository.name + '/extensions/npm/publish')
            .form-group
              label(for='branch') Branch to publish
              select.form-control#branch(name='branch')
                each branch in branches
                  option(value=branch.name, selected=branch.name == 'master')= branch.name

            .form-group
              label NPM collaborator
              input.form-control(disabled=true, value=npmUsername)

            .form-group
              label(for='collaborators') Additional collaborators
              = ' (optional, comma-separated NPM usernames)'
              input.form-control#collaborators(name='collaborators', placeholder='Additional collaborators')

            if userChoiceError
              .checkbox
                label
                  input#acknowledge(type='checkbox', name='acknowledge')
                  strong I acknowledge that my package build scripts will not be executed
                  br
                  | Your #[code package.json] file contains scripts that will not be executed, as this is a publishing service and not a full-fledged build provider.

            p: input.btn.btn-primary(type='submit', value='Publish')

        .col-md-4
          p This self-service tool will publish the branch as an NPM package from an official account.
          p.
            After publishing, your NPM account, #[strong= npmUsername] will be able to publish package
            updates in the future.
          p You can also authorize other users to publish the package.
